package com.jason.data.agentbase;

import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

//@MDS("my")
@Service
public class MyService implements ApplicationContextAware {

    ApplicationContext applicationContext;
    @MDS("my")
    public void run(){
        System.out.println("11111");
    }

    public void run2(){
//        run();
//        applicationContext.getBean(MyService.class).run();

        try {
            Object proxy = AopContext.currentProxy();
            if( proxy!=null){
                ((MyService)proxy).run();
            }else{
                System.out.println("没有代理");
            }
        }catch (Exception e){
            System.out.println("没有代理");
        }


    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
